package com.project.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PageException implements ErrorController{

	@Override
	public String getErrorPath() {
		return "/error";
	}
	@RequestMapping("/error")
    public String handleError(HttpServletRequest request){
        //获取statusCode:401,404,500
        Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
        if(statusCode == 401){
             return "redirect:/html/error.html";
        }else if(statusCode == 404){
        	 return "redirect:/html/error.html";
        }else if(statusCode == 403){ 
        	 return "redirect:/html/error.html";
        }else{
        	 return "redirect:/html/error.html";
        }

    }
}